package cn.demo.gecco.geccobean;

import com.geccocrawler.gecco.annotation.PipelineName;
import com.geccocrawler.gecco.pipeline.Pipeline;
import com.geccocrawler.gecco.request.HttpRequest;
import com.geccocrawler.gecco.scheduler.SchedulerContext;
import org.springframework.util.StringUtils;

/**
 * @ClassName:
 * @PackageName: cn.demo.gecco.geccobean
 * @author: youjp
 * @create: 2019-11-06 11:00
 * @description:  todo 后续业务处理单元
 * @Version: 1.0
 */
@PipelineName("nextPageSortPipeline")
public class NextPageSortPipeline implements Pipeline<NextPageSort> {

    private static Integer num=0;

    @Override
    public void process(NextPageSort nextPageSort) {
       // System.out.println("==========单页房屋信息处理管道==========start"+num++);

        for(int i=0;i<nextPageSort.getHouseInfoList().size();i++){
            HttpRequest currRequest = nextPageSort.getRequest();
            System.out.println(nextPageSort.getHouseInfoList().get(i));    //获取单个房屋信息
            HouseInfo houseInfo=nextPageSort.getHouseInfoList().get(i);
            //
            if(!StringUtils.isEmpty(houseInfo.getUrl())){
                //加入队列
               // SchedulerContext.into(currRequest.subRequest(houseInfo.getUrl()));
            }
        }

        //请求下一页
        HttpRequest currRequest = nextPageSort.getRequest();
        SchedulerContext.into(currRequest.subRequest(nextPageSort.getNextPage()));
        System.out.println("==========单页房屋信息处理管道==========end"+num);
    }
}
